        package DAL;

        import java.util.*;
        
        import DBUtil.SQLUtil;
        
        public class Judge {

		//获取裁判表信息列表
		public List<Object> getEntity()
		{
			String sqlCmd="select *from Judge";
			return DBUtil.SQLUtil.executeQuery(sqlCmd, null);//执行查询操作executeQuery
		}
            
               //获取分页后裁判表信息列表
		public List<Object> getEntity(int page)
		{
			int size=(page-1)*15;
			String sqlCmd="select *from Judge limit "+size+",15";
			return DBUtil.SQLUtil.executeQuery(sqlCmd, null);//执行查询操作executeQuery
		}
                
               //根据查询条件sqlWhere获取分页后裁判表信息列表
		public List<Object> getEntityByWhere(String sqlWhere,int page)
		{
			int size=(page-1)*15;
			String sqlCmd="select *from Judge where "+sqlWhere+" limit "+ size+",15";
			return DBUtil.SQLUtil.executeQuery(sqlCmd, null);//执行查询操作executeQuery
        }
        
        //删除裁判表信息
        public int deleteEntity(String JId)
        {
            String sqlCmd="delete from Judge where JId='"+JId+"'";
            return DBUtil.SQLUtil.executeNonQuery(sqlCmd, null);//执行非查询操作executeNonQuery
        }
        
        //根据裁判表编号获取裁判表信息
        public List<Object> getEntityById(String JId)
        {
            String sqlCmd="select *From Judge where JId='"+JId+"'";
            return DBUtil.SQLUtil.executeQuery(sqlCmd, null);//执行查询操作executeQuery
        }
        
        //更新裁判表信息
        public int updateEntity(String JId,String JName,String JSex)
        {
            String sqlCmd="Update Judge set JName='" + JName + "',JSex='" + JSex + "' where JId='"+JId+"'";
            return SQLUtil.executeNonQuery(sqlCmd, null);
        }
        
        //插入裁判表信息
        public int insertEntity(String JId,String JName,String JSex)
        {
            String sqlCmd="Insert into Judge values('" + JId + "','" + JName + "','"+JSex+"')";
            return SQLUtil.executeNonQuery(sqlCmd, null);
        }
        
        //检查插入主键是否重复
        public boolean checkExist(String JId)
        {
            String sqlCmd="select count(*) from Judge where JId='"+JId+"'";
            if(1==Integer.parseInt(SQLUtil.excuteScalar(sqlCmd, null).toString()) )
            {
                return true;
            }
            return false;
        }

		//获取分页总数
		public Object getPageCount()
		{
			String sqlCmd="SELECT CEIL( COUNT(*)/15.0) FROM Judge ";
			return SQLUtil.excuteScalar(sqlCmd, null);
		}

		//根据查询条件获取分页总数
		public Object getPageCountByWhere(String sqlWhere)
		{
			String sqlCmd="SELECT CEIL( COUNT(*)/15.0) FROM Judge where "+sqlWhere;
			return SQLUtil.excuteScalar(sqlCmd, null);
		}
            
        }
